databaseChangeLog:

  - changeSet:
      id: 12
      author: goosly
      changes:
        - createTable:
            tableName: operation_records
            columns:
              - column:
                  name: record_id
                  type: BIGINT
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    primaryKeyName: op_record_pk
                    nullable: false
              - column:
                  name: operation_name
                  type: VARCHAR(255)
                  constraints:
                    nullable: false
              - column:
                  name: count
                  type: integer
              - column:
                  name: daily_total_id
                  type: BIGINT
                  constraints:
                    nullable: false
        - createTable:
            tableName: daily_totals
            columns:
              - column:
                  name: total_id
                  type: BIGINT
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    primaryKeyName: daily_total_pk
                    nullable: false
              - column:
                  name: date
                  type: DATE
                  constraints:
                    nullable: false
              - column:
                  name: submitted_by
                  type: VARCHAR(255)
                  constraints:
                    nullable: false
              - column:
                  name: department_id
                  type: BIGINT
                  constraints:
                    nullable: false
              - column:
                  name: total
                  type: integer
                  constraints:
                    nullable: false

  - changeSet:
      id: 13
      author: goosly
      changes:
        - addForeignKeyConstraint:
            baseTableName: daily_totals
            baseColumnNames: department_id
            constraintName: daily_total_department_fk
            deferrable: false
            initiallyDeferred: false
            referencedTableName: departments
            referencedColumnNames: department_id
        - addForeignKeyConstraint:
            baseTableName: operation_records
            baseColumnNames: daily_total_id
            constraintName: op_record_daily_total_fk
            deferrable: false
            initiallyDeferred: false
            referencedTableName: daily_totals
            referencedColumnNames: total_id

  #  - changeSet:
  #      id: 14
  #      author: goosly
  #      changes:
  #        - renameTable:
  #            newTableName: daily_totals
  #            oldTableName: daily_total
  #
  #  - changeSet:
  #      id: 15
  #      author: goosly
  #      changes:
  #        - addColumn:
  #            tableName: daily_totals
  #            columns:
  #              - column:
  #                  name: total
  #                  type: integer
  #                  constraints:
  #                    nullable: false
  #
  #  - changeSet:
  #      id: 16
  #      author: goosly
  #      changes:
  #        - addUniqueConstraint:
  #            columnNames: date
  #            constraintName: dt_date_uq
  #            tableName: daily_totals
  #
  #  - changeSet:
  #      id: 17
  #      author: goosly
  #      changes:
  #        -  dropUniqueConstraint:
  #             constraintName: dt_date_uq
  #             tableName: daily_totals
  #             uniqueColumns: date



  - changeSet:
      id: create-string-operation-records-table
      author: goosly
      changes:
        - createTable:
            tableName: string_operation_records
            columns:
              - column:
                  name: record_id
                  type: BIGINT
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    primaryKeyName: str_op_record_pk
                    nullable: false
              - column:
                  name: operation_name
                  type: VARCHAR(255)
                  constraints:
                    nullable: false
              - column:
                  name: value
                  type: VARCHAR(255)
              - column:
                  name: daily_total_id
                  type: BIGINT
                  constraints:
                    nullable: false

  - changeSet:
      id: fk-str_op_rec-to-daily-total
      author: goosly
      changes:
        - addForeignKeyConstraint:
            baseTableName: string_operation_records
            baseColumnNames: daily_total_id
            constraintName: str_op_record_daily_total_fk
            deferrable: false
            initiallyDeferred: false
            referencedTableName: daily_totals
            referencedColumnNames: total_id